﻿using System;
using System.Data;
using System.Data.SqlClient;

namespace Tamias.DefaultImplementation.Data
{
    public class ParameterCollection : System.Collections.ObjectModel.Collection<SqlParameter>
    {

        public SqlParameter Add(string name, int value)
        {
            SqlParameter param = new SqlParameter(name, SqlDbType.Int);
            param.Value = value;
            Add(param);

            return param;
        }

        public SqlParameter Add(string name, string value, int length)
        {
            return Add(name, value, length, true);
        }

        public SqlParameter Add(string name, string value, int length, bool isUnicode)
        {
            SqlParameter param = new SqlParameter(name, isUnicode ? SqlDbType.NVarChar : SqlDbType.VarChar, length);
            if (String.IsNullOrEmpty(value))
                param.Value = DBNull.Value;
            else
                param.Value = value;
            Add(param);

            return param;
        }

    }
}
